<template>
  <div id="renderContent">
    <div class="bubbleContentHeader"></div>
    <iframe
      ref="iframe"
      allow="camera *;microphone *;autoplay *;"
      frameborder="0"
    ></iframe>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        APP_ID: 'c8249181-c642-4c33-aa23-6a9eeb2a8bca', // 替换为您的APP_ID
        APP_CODE: 'embed3x03d18f7ZsSYWc4JTy2', // 替换为您的APP_CODE
      };
    },
    mounted() {
      const isMobile = () => {
        const userAgent = navigator.userAgent || navigator.vendor || window.opera;
        return /android|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(userAgent.toLowerCase());
      };

      const type = isMobile() ? '' : 'full';
      const renderUrl = `https://wx.baeapps.com/api/ai_apaas/v1/web_embed/html?type=${type}&app_id=${this.APP_ID}&code=${this.APP_CODE}`;

      this.$refs.iframe.src = renderUrl; // 设置iframe的src
    },
  };
</script>

<style scoped>
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }

  html,
  body,
  #renderContent {
    width: 100%;
    height: 100%;
  }

  #renderContent {
    display: flex;
    flex-direction: column;
    overflow: auto;
    background: #f3f5f9;
  }

  iframe {
    border: 0;
    display: block;
    flex: 1;
  }

  .bubbleContentHeader {
    padding: 16px 16px 20px 16px;
    display: flex;
    align-items: center;
    flex-direction: row-reverse;
  }
</style>
